import { createApp } from 'vue'
import Xtxconfirm from './xtx-confirm.vue'
export default function (obj) {
  return new Promise((resolve, reject) => {
    const app = createApp(Xtxconfirm, { ...obj, rejectFn, resolveFn })
    const div = document.createElement('div')
    document.body.appendChild(div)
    app.mount(div)
    function resolveFn () {
      remove()
      resolve()
    }
    function rejectFn () {
      remove()
      /* eslint-disable */
      reject()
      //   resolve()
    }
    function remove() {
      app.unmount(div)
      document.body.removeChild(div)
    }
  })
}
